<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加角色</title>
    <link rel="stylesheet" th:href="@{/src/css/layui.css}">
</head>
<body>
<form class="layui-form" style="width:80%;" id="arf">
    <!-- 权限提交隐藏域 -->
    <input type="hidden" id="id" name="id" th:value="${plot.id}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">小区名称</label>
        <div class="layui-input-block">
            <input type="text" id="plotName" class="layui-input plotName" lay-verify="required"
                   placeholder="请输入小区名称" name="plotName" th:value="${plot.plotName}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">小区位置</label>
        <div class="layui-input-block">
            <input type="text" id="plotPlace" class="layui-input plotPlace" lay-verify="required"
                   placeholder="请输入小区位置" name="plotPlace" th:value="${plot.plotPlace}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">物业公司</label>
        <div class="layui-input-block">
            <select name="proId" lay-verify="" style="width: 200px">
                <option value="">-请选择物业-</option>
                <option th:each="p:${propertys}" th:value="${p.id}" th:selected="${p.id == plot.proId}">[[${p.company}]]</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="editPerm">立即提交</button>
        </div>
    </div>
</form>
<script th:src="@{/src/layui.js}"></script>
<script th:src="@{/src/js/jquery-1.9.1.min.js}"></script>
<script>

        layui.use(['form','jquery','layer'],function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer;
            form.on('submit(editPerm)',function (data) {
               $.ajax({
                   url:'/plot/update',
                   data:data.field,
                   type:'put',
                   dataType:'json',
                   success:function (result) {
                       if(result.code == 200){
                           layer.msg('编辑成功',{icon:1},function () {
                               top.layer.closeAll('iframe');
                               //重新加载数据
                               parent.location.reload();
                           })
                       }else{
                           layer.msg(result.message,{icon:5});
                       }
                   }
               })

               return false;
            })
        })
</script>
</body>
</html>